<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<meta charset="UTF-8" />
<title>添加链接</title>
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1" />
<link href="http://layui.hcwl520.com.cn/layui-v2.4.5/css/layui.css?v=201811010202" rel="stylesheet"></link>

</head>
<body>
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  		<legend>修改评论</legend>
	</fieldset>
	<form class="layui-form"  >
				<div class="layui-form-item" >
					<label class="layui-form-label">昵称</label>
					<div class="layui-input-block">
							 <input type="hidden" th:value="${articleComment.id}" id="id" name="id"> 
						<input type="text"  placeholder="请输入昵称"
							autocomplete="off" class="layui-input" lay-verify="required" id="nickName" name="nickName" th:value="${articleComment.nickName}" />
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">头像</label>
					<button type="button" class="layui-btn" id="iconPicButton">
  						<i class="layui-icon">&#xe67c;</i>上传头像
					</button> 
					<img  height="60" width="60" id="headImg"  th:src="${articleComment.headImg}"/>
					<input type="hidden" name="headImg"   id="headImg" th:value="${articleComment.headImg}"/>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">评论内容</label>
					<div class="layui-input-block">
						<input type="text"  placeholder="请输入评论内容"
							autocomplete="off" class="layui-input" lay-verify="required" id="content" name="content" th:value=${articleComment.content} />
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">点赞数</label>
					<div class="layui-input-block">
						<input type="text"  placeholder="请输入点赞数"
							autocomplete="off" class="layui-input" id="likeNum"  name="likeNum" value="0"  lay-verify="number" th:value="${articleComment.likeNum}"/>
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">回复内容</label>
					<div class="layui-input-block">
						<input type="text"  placeholder="请输入回复内容"
							autocomplete="off" class="layui-input"  id="replyContent" name="replyContent" th:value="${articleComment.replyContent}" />
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">回赞数</label>
					<div class="layui-input-block">
						<input type="text"  placeholder="请输入回赞数"
							autocomplete="off" class="layui-input" id="replyLikeNum"  name="replyLikeNum" value="0"   th:value="${articleComment.replyLikeNum}"/>
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">是否显示</label>
					 <div class="layui-input-block">
						 <input type="checkbox"  lay-filter="switchShow"  lay-skin="switch" lay-text="显示|隐藏"  th:attr ="checked = ${articleComment.isShow==1?true:false}">
						 <input type="hidden"  name="isShow" id="isShow" th:value="${articleComment.isShow}"/>
					</div>
				</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">显示置顶</label>
					 <div class="layui-input-block">
						 <input type="checkbox" lay-filter="switchTop"  lay-skin="switch" lay-text="显示|隐藏"  th:attr ="checked = ${articleComment.isTop==1?true:false}">
						 <input type="hidden"  name="isTop" id="isTop" th:value="${articleComment.isTop}"/>
						 <input type="hidden"  name="rId" id="rId" th:value="${articleComment.rId}"/>
						 <input type="hidden"  name="ip" id="ip" th:value="${articleComment.ip}"/>
						 <input type="hidden"  name="isDel" id="isDel" th:value="${articleComment.isDel}"/>
					</div>
				</div>
			    <div class="layui-input-block" style="display: none">
			      <button class="layui-btn" lay-submit="" lay-filter="edit" id="articleCommentSubmint" >立即提交</button>
			      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
   				 </div>
			</form>		
</body>
<script type="text/javascript" src="http://layui.hcwl520.com.cn/jquery/jquery-3.3.1.min.js?v=201804251754"></script>
<script type="text/javascript" src="http://layui.hcwl520.com.cn/layui-v2.4.5/layui.all.js?v=201811010202"></script>
<script th:inline="javascript">
$(function(){ 
	layui.use('form', function(){
		  var form = layui.form; 
		  form.render();
		  form.on('switch(switchShow)', function(data){
		  	if(!this.checked){
		  		$("#isShow").val("0");
		  	}else{
		  		$("#isShow").val("1");
		  	}
		  });  
		  form.on('switch(switchTop)', function(data){
			  if(!this.checked){
			  		$("#isTop").val("0");
			  	}else{
			  		$("#isTop").val("1");
			  	}
		  });  
		  form.on('submit(edit)', function(data){
		    if(data.field.headImg==''){
		    	layer.msg("请上传头像");
		    	return false;
		    } 
		    $.ajax({
	            //几个参数需要注意一下
	                type: "POST",//方法类型
	                url: "editArticleComment" ,//url
	                data: JSON.stringify(data.field),
	                contentType: 'application/json',
	                success: function (result) {
	                    if (result == "success") {
							parent.layer.msg('添加成功', {
								icon : 6,
							});
							parent.layer.closeAll('iframe'); 
	                    }else{
	                    	parent.layer.msg('出现网络故障', {
								icon : 5,
							});
							parent.layer.closeAll('iframe'); 
	                    }
	                },
	                error : function() {
	                    layer.alert("异常");
	                }
	            });
		      return false;
		  });
		});
	layui.use('upload', function(){
	  var $ = layui.jquery
	  ,upload = layui.upload;
	  upload.render({
		    elem: '#iconPicButton'
		    ,url: '/ueditor/imgUpdate'
		    ,accept:'images'
		    ,size: 5120 //限制文件大小，单位 KB
		    ,done: function(res){
		      if(res.state=='SUCCESS'){
		    	  $("#iconPic").show();
		    	  $("#iconPic").attr('src',res.url);
		    	  $("#imgUrl").val(res.url);
		    	  layer.msg("上传成功");
		      }else{
		    	  layer.msg("上传失败");
		      }
		    }
		  });
		});	
	}); 
</script>
</html>

